1 module unde.games.dizzy.omega.animations.ground_castle; 2 3 import derelict.opengl3.gl; 4 import std.conv; 5 import std.format; 6 import std.math; 7 import std.stdio; 8 import unde.games.collision_detector; 9 import unde.games.dizzy.omega.dizzy; 10 import unde.games.dizzy.omega.main; 11 import unde.games.object; 12 import unde.games.renderer; 13 import unde.global_state; 14 15 class GroundCastle:StaticGameObject 16 { 17 this(MainGameObject root) 18 { 19 frame = -1; 20 models["ground-castle"] = root.models["ground-castle"]; 21 models["ground-castle-1"] = root.models["ground-castle-1"]; 22 23 super(root); 24 } 25 26 override void draw(GlobalState gs) 27 { 28 DizzyOmega dz = cast(DizzyOmega) root; 29 30 if (abs(root.scrx - 16*30.0) > 35.0 || root.scry != -9*17.0) 31 return; 32 33 glPushMatrix(); 34 if (frame < 0) 35 { 36 recursive_render(gs, models["ground-castle"]); 37 } 38 else 39 { 40 recursive_render(gs, models["ground-castle-1"]); 41 } 42 glPopMatrix(); 43 } 44 45 override bool tick(GlobalState gs) 46 { 47 DizzyOmega dz = cast(DizzyOmega) root; 48 49 if (frame >= 0 && root.frame - frame == 1) 50 { 51 dz.collision_objects["solid"]["Wall1"] = null; 52 dz.collision_objects["solid"].remove("Wall1"); 53 reset_collision_cache(); 54 } 55 return true; 56 } 57 58 override void load(string[string] s) 59 { 60 string p = "groundcastle"; 61 if (p in s) 62 frame = s[p].to!(long); 63 else 64 frame = -1; 65 66 DizzyOmega dz = cast(DizzyOmega) root; 67 if (frame < 0 || root.frame - frame < 1) 68 { 69 dz.collision_objects["solid"]["Wall1"] = 70 dz.collision_objects["temp-solid"]["Wall1"]; 71 reset_collision_cache(); 72 } 73 else 74 { 75 dz.collision_objects["solid"]["Wall1"] = null; 76 dz.collision_objects["solid"].remove("Wall1"); 77 reset_collision_cache(); 78 } 79 } 80 81 override void save(ref string[string] s) 82 { 83 if (frame >= 0) 84 { 85 string p = "groundcastle"; 86 s[p] = frame.to!(string); 87 } 88 } 89 }